<%@ page contentType="text/html;charset=UTF-8"%>
<script type="text/javascript">
	$(function() {
		$("#register_form").validate({
			rules : {
				username : {
					required : true,
					minlength : 3,
					maxlength : 15
				},
				password : {
					required : true
				},
				password2 : {
					required : true,
					equalTo : "#password"
				},
				email : {
					required : true,
					email : true
				}
			},
			messages : {
				username : {
					required : '用户名由3到15个字符组成',
					minlength : '用户名不得小于3个字符',
					maxlength : '用户名不得大于15个字符'
				},
				password : {
					required : '请填写密码'
				},
				password2 : {
					required : '请再次输入密码',
					equalTo : "两次输入的密码不一致"
				},
				email : {
					required : '请输入正确的邮箱地址',
					email : 'Email地址无效'
				}
			}
		});

		function register_success(data) {
			if (data.state == 'success') {
				$('#register').css('display', 'none');
				$('#register_success').css('display', 'block');
				setTimeout(function() {
					window.location = 'index.do';
				}, 3000);
			} else {
				alert('注册失败');
			}
		}

		$('#register_form').ajaxForm({
			success : register_success
		});

		$('#username').select();
	});
</script>
<div id="register" class='register'>
	<div class='register_header'>立即注册</div>
	<div class='register_content'>
		<form id='register_form' action="login/register.do" method="post">
			<table>
				<tr>
					<td class="register_td1"><span class='red'>*</span>用户名</td>
					<td class="register_td2"><input id='username' name='username' /></td>
				</tr>
				<tr>
					<td class="register_td1"><span class='red'>*</span>密码</td>
					<td class="register_td2"><input id='password' name='password' type='password' /></td>
				</tr>
				<tr>
					<td class="register_td1"><span class='red'>*</span>确认密码</td>
					<td class="register_td2"><input id='password2' name='password2' type='password' /></td>
				</tr>
				<tr>
					<td class="register_td1"><span class='red'>*</span>Email</td>
					<td class="register_td2"><input id='email' name='email' /></td>
				</tr>
				<tr>
					<td colspan="2" class="register_td3"><button class='register_button' onclick="$('#register_form').submit();return false;">提交</button></td>
				</tr>
			</table>
		</form>
	</div>
</div>
<div id="register_success" class='autojump' style='display: none;'>
	<a href='index.do'>如果您的浏览器没有自动跳转，请点击此链接</a>
</div>